/*
 * MySQL.h
 *
 *  Created on: 05.09.2013
 *      Author: radu
 */

#ifndef MYSQL_H_
#define MYSQL_H_

#include "my_gtk.h"
#include "my_string.h"
#include <driver/mysql_public_iface.h>

typedef struct
{
  gchar* product;
}
Prod;

enum
{
  COLUMN_PRODUCT_TEXT,
  NUM_PRODUCT_COLUMNS
};

using namespace sql;

extern Driver *driver;
extern Connection *con;
extern Statement *stmt;
extern ResultSet *res;
extern string fld_arr[20];
extern string tbl_name;
extern stringstream sql_str;
extern gint fld_cnt;
extern GType TypeArr[20];
extern GArray *products;
extern GtkWidget *entry1;
extern GtkWidget *entry2;

class My_SQL {
public:
	My_SQL();

	static void fld_extract();

	static void types_extract();
	static gboolean foreach_func (GtkTreeModel *model,
	                GtkTreePath  *path,
	                GtkTreeIter  *iter,
	                gpointer      user_data);

	static void	add_products ();
	static GtkTreeModel *create_items_model (void);
	static GtkTreeModel *create_products_model (void);
	static void save_items(GtkWidget *button, gpointer data);
	virtual ~My_SQL();
};

#endif /* MYSQL_H_ */
